wayland: Apply maximized and fullscreen state
authorMatthias Clasen <mclasen@redhat.com>
Fri, 27 Feb 2015 23:18:00 +0000 (23:18 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 28 Feb 2015 00:09:03 +0000 (19:09 -0500)
We were just throwing the request away if the app asks to
fullscreen or maximize a window before it has been mapped.
This is something the GdkWindow API explicitly supports,
so make it work by saving the state until the surface exists.

This fixes things under weston. There are bugs in mutter
that keep this from working correctly with gnome-shell.

https://bugzilla.gnome.org/show_bug.cgi?id=745303

gdk/wayland/gdkwindow-wayland.c

index 8a449ff488e486d9005b1f308f43d2da487cc926..cc0d3b4c99077360dbb71a696ed818072d5aeb9e 100644 (file)
@@ -953,6 +953,12 @@ gdk_wayland_window_create_xdg_surface (GdkWindow *window)
   gdk_wayland_window_sync_parent (window);
   gdk_wayland_window_sync_title (window);
   gdk_wayland_window_sync_margin (window);
+
+  if (window->state & GDK_WINDOW_STATE_MAXIMIZED)
+    xdg_surface_set_maximized (impl->xdg_surface);
+  if (window->state & GDK_WINDOW_STATE_FULLSCREEN)
+    xdg_surface_set_fullscreen (impl->xdg_surface, NULL);
+
   xdg_surface_set_app_id (impl->xdg_surface, gdk_get_program_class ());
 }
 
@@ -1757,10 +1763,10 @@ gdk_wayland_window_maximize (GdkWindow *window)
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  if (!impl->xdg_surface)
-    return;
-
-  xdg_surface_set_maximized (impl->xdg_surface);
+  if (impl->xdg_surface)
+    xdg_surface_set_maximized (impl->xdg_surface);
+  else
+    gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_MAXIMIZED);
 }
 
 static void
@@ -1771,10 +1777,10 @@ gdk_wayland_window_unmaximize (GdkWindow *window)
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  if (!impl->xdg_surface)
-    return;
-
-  xdg_surface_unset_maximized (impl->xdg_surface);
+  if (impl->xdg_surface)
+    xdg_surface_unset_maximized (impl->xdg_surface);
+  else
+    gdk_synthesize_window_state (window, GDK_WINDOW_STATE_MAXIMIZED, 0);
 }
 
 static void
@@ -1785,10 +1791,10 @@ gdk_wayland_window_fullscreen (GdkWindow *window)
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  if (!impl->xdg_surface)
-    return;
-
-  xdg_surface_set_fullscreen (impl->xdg_surface, NULL);
+  if (impl->xdg_surface)
+    xdg_surface_set_fullscreen (impl->xdg_surface, NULL);
+  else
+    gdk_synthesize_window_state (window, 0, GDK_WINDOW_STATE_FULLSCREEN);
 }
 
 static void
@@ -1799,10 +1805,10 @@ gdk_wayland_window_unfullscreen (GdkWindow *window)
   if (GDK_WINDOW_DESTROYED (window))
     return;
 
-  if (!impl->xdg_surface)
-    return;
-
-  xdg_surface_unset_fullscreen (impl->xdg_surface);
+  if (impl->xdg_surface)
+    xdg_surface_unset_fullscreen (impl->xdg_surface);
+  else
+    gdk_synthesize_window_state (window, GDK_WINDOW_STATE_FULLSCREEN, 0);
 }
 
 static void